package com.smart_campus.sys.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.smart_campus.sys.common.DataGridView;
import com.smart_campus.sys.domain.Loginfo;
import com.smart_campus.sys.vo.LoginfoVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

import com.smart_campus.sys.mapper.LoginfoMapper;
import com.smart_campus.sys.service.LoginfoService;

import java.util.List;

/**
 * @author Alfred
 * @time: 2020/6/21 20:17
 */
@Service
public class LoginfoServiceImpl implements LoginfoService {

    @Resource
    private LoginfoMapper loginfoMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return loginfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Loginfo record) {
        return loginfoMapper.insert(record);
    }

    @Override
    public int insertSelective(Loginfo record) {
        return loginfoMapper.insertSelective(record);
    }

    @Override
    public Loginfo selectByPrimaryKey(Integer id) {
        return loginfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Loginfo record) {
        return loginfoMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Loginfo record) {
        return loginfoMapper.updateByPrimaryKey(record);
    }

    /**
     * 分页方法
     *
     * @param loginfoVo
     * @return DataGridView
     */
    @Override
    public DataGridView selectloginfo(LoginfoVo loginfoVo) {
        Page<Object> page = PageHelper.startPage(loginfoVo.getPage(), loginfoVo.getLimit());//分页数据格式
        List<LoginfoVo> loginfoVos = loginfoMapper.selectloginfo(loginfoVo);//返回的全部数据
        return new DataGridView(page.getTotal(), loginfoVos);
    }

}

